{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "7a19a6d2",
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "V = 1.0 # max obstacle speed\n",
    "b = 1.0 # max braking\n",
    "A = 1.0 # max accel\n",
    "e = 0.1 # sampling period\n",
    "\n",
    "p_r = (0.0, 0.0) # robot's position\n",
    "p_o = (1.0, 1.0) # obstacle position. c.f. (1000,1000)\n",
    "v_r = 1.0 # robot speed"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "df67a01b",
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# intermediate constants\n",
    "a0 = (A/b+1.0)*((A/2.0)*e*e+e*V)\n",
    "a1 = V/b+e*(A/b+1.0)\n",
    "a2 = 1.0/(2.0*b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "id": "e959b8f5",
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "p = a2*v_r*v_r + a1*v_r + a0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "id": "586e2bd0",
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Chebyshev distance\n",
    "cheb = max(abs(p_r[0]-p_o[0]), abs(p_r[1]-p_o[1]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "id": "7d631316",
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "safe = p < cheb"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "id": "6e59a619",
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "False\n"
     ]
    }
   ],
   "source": [
    "print(safe)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "argv": [
    "python",
    "-m",
    "ipykernel_launcher",
    "-f",
    "{connection_file}"
   ],
   "display_name": "Python 3 (ipykernel)",
   "env": null,
   "interrupt_mode": "signal",
   "language": "python",
   "metadata": {
    "debugger": true
   },
   "name": "python3"
  },
  "name": "Untitled.ipynb"
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
